<!--审核退款-->
<!doctype html>
<html>
<head>
	<meta charset="UTF-8">
	<title></title>
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<link href="../css/mui.min.css" rel="stylesheet" />
	<link rel="stylesheet" type="text/css" href="../css/mui.picker.min.css"/>
	<link rel="stylesheet" type="text/css" href="../css/order.css"/>
</head>
<body class="gray">
	<div class="mui-content detail loading" id="vueMain">
	    <ul class="mui-table-view" style="margin-top: 0px;">
	        <li class="mui-table-view-cell tls">
	        		NO.{{order}}
	        </li>
	        <li class="mui-table-view-cell mui-media">
	        		<a href="javascript:;">
    		            <img class="mui-media-object mui-pull-left" :src="list.img" />
    		            <div class="mui-media-body">
    		                <div class="name">{{list.name}}</div>
    		                <p v-if="list.stro"><span class="mui-pull-right"></span>已选：{{list.stro}}</p>
    		                <p>数量:{{list.amount}}</p>
    		            </div>
    		             <p class="total">已支付金额: <span >¥ {{list.real_price}}</span> </p>
    		        </a>
	        </li>
    		</ul>
    		<ul class="mui-table-view itemlist">
	        <li class="mui-table-view-cell sel" style="padding:12px 15px">
	            <a class="mui-navigate-right">
	               <span class="mui-pull-right dnf">请选择</span>
	               审核
	            </a>
	        </li>
	    </ul>
	    <div class="mui-input-row" style="background: #FFF;margin-top: 10px;" v-if="isActive==2">
	        <label>退款金额</label> 
	        <input type="text" v-model="money"  placeholder="请输入退款金额" />
	    </div>
	    <div class="item" v-if="isActive==1">
	    		<textarea name="" placeholder="请写下您处理的具体理由" v-model="content"></textarea>
	    		<!--<p class="total-text">500</p>-->
	    </div>
	    
	    <div class="mui-content-padded" style="padding: 25px 0;">
	    		<button type="button" class="mui-btn mui-btn-block bexta-btn bexta-btn-red tijiao" >提交</button>
	    </div>
	</div>
<script src="../js/mui.min.js"></script>
<script src="../js/vue.min.js"></script> 
<script src="../js/mui.picker.min.js"></script>
<script src="../js/bexta.js"></script>
<script type="text/javascript">
	var apps, views, merchant;
	mui.init();
	mui.plusReady(function () {
	   views = bexta.getWebview();
	   merchant = bexta.getStorage(MERCHANT);
	   bexta.ajax(api.refound_page, function(res){
	   		initVue(res);
	   }, {data:{uid:merchant.uid, order_no:views.order}});
	});
	function initVue(res){
		apps = new Vue({
			el:"#vueMain",
			data:{
				order:views.order,
				list:res,
				isActive:0,
				money:"",
				content:""
			},
			mounted:function(){
				document.querySelector('.loading').classList.add('loadRun');
				var self = this;
				var picker = new mui.PopPicker(); 
				picker.setData([{
					value:"1",
					text:"拒绝"
				},{
					value:"2",
					text:"同意"
				}]);
				
				document.querySelector('.sel').addEventListener('tap', function(){
					mui.each(document.querySelectorAll('input'), function(){
						this.blur();
					});
					var that = this;
					picker.show(function(item){
						that.querySelector('span').innerHTML = item[0].text;
						self.isActive = item[0].value;
					});
				});
				
				document.querySelector('.tijiao').addEventListener('tap', function(){
					if( self.isActive == 0 ){
						mui.toast("请同意或拒绝");
						return ;
					}
					if( self.isActive == 2  && self.money < 1 ){
						mui.toast("请输入退款金额");
						return ;
					}
					if( self.isActive == 1  && self.content == "" ){
						mui.toast("处理意见未填");
						return ;
					}
					bexta.ajax(api.save_refund, function(res,msg){
						mui.toast(msg);
						if( !res ){
							mui.fire(views.opener().opener(), 'reloading')
							views.opener().close('none');
							mui.later(function(){
								mui.back();
							}, 500);
							
						}
					}, {data:{uid:merchant.uid, order_no:self.order,method:self.isActive, content:self.content, money:self.money}});
				});
				
			}
		});
	}
	
	
	
	
	
</script>
</body>
</html>